package com.lanqiao.service.impl;

import com.lanqiao.domain.UsersInfo;
import com.lanqiao.mapper.UserInfoMapper;
import com.lanqiao.service.IUserInfoService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 张建平 on 2020/8/11.
 */
@Service("userInfoService")  // bean id: userInfoServiceImpl
public class UserInfoServiceImpl implements IUserInfoService {

    static Logger logger = Logger.getLogger(UserInfoServiceImpl.class);

    // 注入Mapper映射接口
    @Autowired
    UserInfoMapper userInfoMapper; // bean id: @Repository

    @Override
    public UsersInfo selectForLogin(UsersInfo usersInfo) {
        return userInfoMapper.selectForLogin(usersInfo);
    }

    @Override
    public int addUserInfo(UsersInfo user) {
        int i = userInfoMapper.insert(user);

        logger.debug(">>>> 数据操库作已执行");
        // 模拟异常的发生
        if (true) {
            //throw new RuntimeException("注册用户发生异常.");
        }
        return i;
    }
}
